import { AstContext } from "../../../context";
import { PageVisitor } from "../pageVisitor";

export function parseChildren(visitor: PageVisitor, ast: AutoJs.UiObject, ctx: AstContext, key: string) {
    const items: any[] = []
    ctx.eachChild(ast, node => {
        if(!node.visibleToUser()) return;
        const c = ctx.create()
        visitor.visit(node, c)
        const obj = c.all()
        if (obj && Object.keys(obj).length > 0) {
            items.push(obj)
        }
    })
    ctx.set(key, items)
    return true;
}